package com.igeek.boot.config;

import com.igeek.boot.quartz.MyQuartJob;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @package com.igeek.boot.config
 * @Description quartzJob配置类
 * @Author LittlePunk [296526219@qq.ccom]
 * @Version 2022.1
 * @Date 2023/12/21 10:02
 */
@Configuration
public class QuartConfig {

    //任务明细
    //@Bean
    public JobDetail printJobDetail(){
        //构建job工作，通过newJob（）指定工作明细  storeDurably()将任务持久化
        return JobBuilder.newJob(MyQuartJob.class).storeDurably().build();
    }
    //触发器
    //@Bean
    public Trigger printTrigger(){
        //构建调度器 cron表达式 规定任务执行时间
        ScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule("0/20 * * * * ? ");
        return  TriggerBuilder.newTrigger().forJob(printJobDetail()).withSchedule(scheduleBuilder).build();
    }
}
